package com.ai.mall.controller.admin;

import com.ai.mall.entity.OrderStatusHistoryEntity;
import com.ai.mall.service.OrderStatusHistoryService;
import com.ai.mall.utils.PageUtils;
import com.ai.mall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 订单状态历史表
 *
 * @author easue
 * @email sunlightcs@gmail.com
 * @date 2025-01-21 14:40:34
 */
@RestController
@RequestMapping("mall/orderstatushistory")
public class OrderStatusHistoryController {
    @Autowired
    private OrderStatusHistoryService orderStatusHistoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("mall:orderstatushistory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderStatusHistoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{historyId}")
    //@RequiresPermissions("mall:orderstatushistory:info")
    public R info(@PathVariable("historyId") Integer historyId){
		OrderStatusHistoryEntity orderStatusHistory = orderStatusHistoryService.getById(historyId);

        return R.ok().put("orderStatusHistory", orderStatusHistory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mall:orderstatushistory:save")
    public R save(@RequestBody OrderStatusHistoryEntity orderStatusHistory){
		orderStatusHistoryService.save(orderStatusHistory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mall:orderstatushistory:update")
    public R update(@RequestBody OrderStatusHistoryEntity orderStatusHistory){
		orderStatusHistoryService.updateById(orderStatusHistory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mall:orderstatushistory:delete")
    public R delete(@RequestBody Integer[] historyIds){
		orderStatusHistoryService.removeByIds(Arrays.asList(historyIds));

        return R.ok();
    }

}
